package com.feihong.yw189.adapter.holder;

import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.feihong.yw189.R;
import com.feihong.yw189.adapter.ExpandAbleListAdapter;
import com.feihong.yw189.model.Spec.SpecInfoModel;

/**
*@author wangziheng
*@Description  套餐viewholder
*@Data 2018/10/11
*/
public class ExpandAbleListHolder {

    /**
     * 套餐详情
     */
    private  RelativeLayout  ivGoDetail;

    /**
     * 套餐组名称
     */
    private TextView mGroupName;
    /**
     * 套餐组标识
     */
    private TextView mGroupSign;
    /**
     * 套餐组信息
     */
    private TextView mGroupInfo;

    /**
     * 子套餐名称
     */
    private TextView mChildPackageName;
    /**
     * 子套餐价格
     */
    private TextView mChildPackagePrice;
    /**
     * 子套餐信息
     */
    private TextView mChildPacakgeInfo;

    private RelativeLayout mKaikaPackageChildLayout;

    public void initParentView(View convertView) {

        this.mGroupName = (TextView) convertView.findViewById(R.id.tv_tianyi);
        this.mGroupSign = (TextView) convertView.findViewById(R.id.tvlable);
        this.mGroupInfo = (TextView) convertView.findViewById(R.id.tv_content);

    }

    public void initChildView(View convertView) {

        this.mChildPackageName = (TextView) convertView.findViewById(R.id.tv_tao);
        this.mChildPackagePrice = (TextView) convertView.findViewById(R.id.tv_sum);
        this.mChildPacakgeInfo = (TextView) convertView.findViewById(R.id.tv_sumtext);
        this.ivGoDetail = (RelativeLayout) convertView.findViewById(R.id.iv_back);
        mKaikaPackageChildLayout = (RelativeLayout) convertView.findViewById(R.id.kaikaPackageChildLayout);
    }

    public void initParentData(SpecInfoModel.DataBean childSpecInfo) {

        mGroupName.setText(childSpecInfo.getSpec_g_name());
        mGroupInfo.setText(childSpecInfo.getInfo());
        mGroupSign.setText("无数据");

    }

    /**
     *
     * @param groupID  套餐组id
     * @param childData
     * @param insertChildPackageDetailListener
     * @param insertChildPackageDetailListener
     */
    public void initChildData(final String groupID, final SpecInfoModel.DataBean.SpecListBean childData, final ExpandAbleListAdapter.InsertChildPackageDetailListener insertChildPackageDetailListener) {

        mChildPackageName.setText(childData.getSpec_name());
        mChildPackagePrice.setText(childData.getPrice());
        mChildPacakgeInfo.setText(childData.getSpec_info());
        childData.setSpecGroupID(groupID);
        mKaikaPackageChildLayout.setOnClickListener(v -> insertChildPackageDetailListener.insertChildPackageDetailListener(childData));

        ivGoDetail.setOnClickListener(v -> insertChildPackageDetailListener.insertChildImageGoDetailListener(childData));
    }
}
